const db = wx.cloud.database();
const app = getApp();
Page({
  data: {
    color: "#FF69B4",
    routers: [{
        name: '校车情况',
        url: 'schoolCar/schoolCar',
        icon: '/icon/luxian.png',
        code: '10'
      },
      {
        name: '贴心攻略',
        url: 'love/love',
        icon: '/icon/tiexin.png',
        code: '11'
      },
      {
        name: '学习',
        url: 'study/study',
        icon: '/icon/study.png',
        code: '12'
      },
      {
        name: '生活',
        url: 'life/life',
        icon: '/icon/life.png',
        code: '13'
      },
      {
        name: '食堂',
        url: 'canteen/canteen',
        icon: '/icon/eat.png',
        code: '14'
      },
      {
        name: '宿舍',
        url: 'dormitory/dormitory',
        icon: '/icon/suse.png',
        code: '15'
      }
    ],
    activeNames: ['0'],
    show: false,
    display: "none"
  },
  onChange(event) {
    this.setData({
      activeNames: event.detail,
    });
  },
  showPopup(e) {
    var that = this;
    db.collection('question').where({
      _id: e.currentTarget.dataset.id
    }).get({
      success: function (res) {
        wx.showModal({
          content: res.data[0].intr,
          showCancel: false,
          confirmText: "知道啦",
          title: res.data[0].title,
        })
      }
    })
  },
  onLoad: function (e) {
    var that = this;
    wx.showLoading({
      title: '加载中...',
    })
    db.collection('question').where({
      isGongGao: false
    }).get({
      success: function (res) {
        that.setData({
          list: res.data
        })
      }
    })
    setTimeout(function () {
      wx.hideLoading({
        success: (res) => {},
      })
      that.setData({
        display: ""
      })
    }, 1000);
  },
  goBoke(){
    wx.setClipboardData({
      data: 'https://tbsg.gitee.io',
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            wx.showModal({
              title: '提示',
              content: '博客地址已复制，前往浏览器查看...',
              showCancel: false
            })
          }
        })
      }
    })
  }
})